package com.ruoyi.master.util;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum TaskStatusEnum implements IEnum<TaskStatusEnum>{
    NORMAL("10","PIN"),
    FILING("20","归档"),
    DELETE("30","删除");

    private String value;
    private String name;

    private static final Map lookup = new HashMap();

    static {
        for(TaskStatusEnum e : EnumSet.allOf(TaskStatusEnum.class)){
            lookup.put(e.getName(), e.getValue());
        }
    }

    /**
     * 构造函数
     * @param value 枚举值
     */
    private TaskStatusEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    /**
     * 获取枚举值
     *
     * @return 枚举值
     */
    public String getValue() {
        return value;
    }

    /**
     * 获取枚举名
     *
     * @return 枚举枚举名
     */
    public String getName() {
        return name;
    }

    /*
     * 判断传入的枚举值(value)与当前的枚举值是否相等
     * @see ICmsEnum#equals(java.lang.String)
     */
    @Override
    public final boolean equals(String value) {
        return this.getValue().equals(value);
    }

    public static Map<String,Object> getMap(){
        Map<String,Object> map=new HashMap<>();
        for(TaskStatusEnum type : TaskStatusEnum.values()){
            map.put( type.getValue(),type.getName());
        }
        return map;
    }

    public static String getName(String value){
        String name = null;
        for(TaskStatusEnum type : TaskStatusEnum.values()){
            if(type.getValue().equals(value) ) {
                name = type.getName();
            }
        }
        return name;
    }

    public static String findValue(String name){
        String defaultValue = "";
        if (name != null){
            defaultValue  = lookup.get(name)+"";
        }
        return defaultValue;
    }
}
